# -*- coding: UTF-8 -*-
# 把ssr节点 放到txt中运行
import base64, requests, os

root_dir = os.path.dirname(os.path.abspath(__file__))
path = root_dir+'/ssr.txt'
res = root_dir+'/ssr'
group = '青年沛铭&54hpm.cn'
group = base64.urlsafe_b64encode(group.encode()).decode().strip('=')
try:
    with open(path,'r') as f:
        txt = f.read()
        txt = txt.strip().split('\n')
        yy = []
        for i in txt:
            j = i.split('ssr://')[1]
            j = j.strip()
            data = base64.urlsafe_b64decode((j + '=' * (-len(j) % 4)).encode()).decode()
            data2 = base64.urlsafe_b64encode((data.split('group=')[0]+'group='+group).encode()).decode()
            data = 'ssr://'+data2.strip('=')
            yy.append(data)
        d = '\n'.join(yy)
        d = (base64.b64encode(d.encode()).decode()).strip('=')
        print (d)
        with open(res,'w+') as ff:
            ff.writelines(d)
except Exception as e:
    print (e)



#  订阅地址
#
# https://raw.githubusercontent.com/JtMingyiqiu/ssr/master/ssr     # 个人
# https://raw.githubusercontent.com/AmazingDM/sub/master/ssrshare.com      #  主 ssr
# https://www.toyo.cf/link/0LR4mmDkAlkX9YjM  # 临时
# https://cmcc.bid/link/cENZOq6kfGC8mLoz?mu=0  #cmcc
#  github地址 https://github.com/zuoshouzz/ssr/blob/master/ssr-python3.py
